const Service = require('egg').Service;

var uuid = require('uuid');

class CsService extends Service {

	async list () {

		const result = await this.app.mysql.get('cs').select('audit_mail_list');

		return result;
	}


	async update (para) {

		const { id, ...p } = para;

		const conn = this.app.mysql.get('cs');

		let result = null;

		if(id == undefined){
			result = await conn.insert('audit_mail_list', {
				id : uuid.v1(),
				...p,
			});
		}else{
			result = await conn.update('audit_mail_list', {
				...para,
			});
		}

		return result.affectedRows === 1;
	}


	async info (id) {

		const conn = this.app.mysql.get('cs');

		const result = await conn.get('audit_mail_list', {id});

		return result;

	}


}

module.exports = CsService;